<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <h:outputStylesheet library="styles" name="estilos.css"/>
        <ui:insert name="cabecera"/>
    </h:head>
    <h:body>
        <h:panelGrid columns="2" width="100%" columnClasses="alil,anc1">
            <h:link outcome="/welcome">
                <h:graphicImage library="images" name="logo.png"/>
            </h:link>
            <h:form>
                <c:if test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">
                    <p:panel header="Conectado como:" style="font-size: 10px">
                        <h:panelGrid columns="2">
                            <h:graphicImage value="#{obtenerAvatar.rutaAvatar()}" height="30" width="30" style="border: 1px solid black"/>
                            <h:outputText value="#{sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.username}" style="font-weight: bolder"/>
                        </h:panelGrid>
                        <f:facet name="footer">
                            <h:panelGrid columns="2" columnClasses="alir,alil" width="100%">
                                <c:if test="${comprobarRol.checkRole('Administrador')}">
                                    <h:link outcome="/secured/adminUsuarios.xhtml" value="Usuarios"/>
                                    <h:link outcome="/secured/adminSecciones.xhtml" value="Secciones"/>
                                </c:if>
                                <c:if test="${comprobarPrivadosNuevos.noLeido}">
                                <h:link outcome="/miPerfil.xhtml" value="Mi Perfil" style="color:green"/>
                                </c:if>
                                <c:if test="${!comprobarPrivadosNuevos.noLeido}">
                                    <h:link outcome="/miPerfil.xhtml" value="Mi Perfil" style="font-size:10px"/>
                                </c:if>
                                 <h:commandLink action="#{loginBean.logout}" value="Desconectar"/>
                            </h:panelGrid>
                        </f:facet>
                    </p:panel>
                </c:if>
                <c:if test="${empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">
                    <p:panel header="Identifícate" style="font-size: 10px">
                        <h:panelGrid columns="2" columnClasses="alir,alil" cellpadding="0">
                            <h:outputLabel for="j_username" value="Usuario: "/>
                            <p:inputText id="j_username" value="#{loginBean.nick}" size="12"/>
                            <h:outputLabel for="j_password" value="Contraseña: "/>
                            <p:password id="j_password" value="#{loginBean.password}" feedback="false" minLength="8" size="12"/>
                        </h:panelGrid>
                        <h:panelGrid columns="3" columnClasses="alir,alil,alir" width="100%" cellpadding="0">
                            <h:selectBooleanCheckbox id="remember"/>
                            <h:outputLabel for="remember" value="Recordar"/>
                            <h:commandButton type="submit" value="Aceptar" action="#{loginBean.doLog}" styleClass="alir"/>
                        </h:panelGrid>
                        <f:facet name="footer">
                            <h:panelGrid width="100%" styleClass="alir">
                                <h:link outcome="/registro" value="Registrarse"/>
                            </h:panelGrid>
                        </f:facet>
                    </p:panel>
                </c:if>
            </h:form>
        </h:panelGrid>
        <hr/>
        <p:messages/>
        <hr/>
        <h:form>
            <ui:insert name="tabla"/>
        </h:form>
        <br/>
        <h:form>
            <ui:insert name="tabla2"/>
        </h:form>
        <h:form style="text-align: center">
            <c:if test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">
                <h:link value="Registrados" outcome="/listUsuarios"/>
                <h:outputText value=" - "/>
            </c:if>
            <h:link value="Ayuda"/>
            <h:outputText value=" - "/>
            <h:link value="Contacto"/>
            <h:outputText value=" - "/>
            <h:link value="Comunidad"/>
            <h:outputText value=" - "/>
            <h:link value="Colabora"/>
            <br/>
            <h:outputText value="@2011 Foroweb-EMR" style="color: #b4b4b4;font-size: 10px"/>
        </h:form>
    </h:body>
</html>
